//
//  UIBttonItem-extension.swift
//  WeiBo
//
//  Created by 涂永江 on 2017/6/4.
//  Copyright © 2017年 涂永江. All rights reserved.
//

import UIKit


 extension UIBarButtonItem
 {
    
    //便利构造函数
    convenience init(title1:String ,target:Any? ,action:Selector ,imageName:String? = nil){
    
        self.init()
        
        let button:UIButton = UIButton()
        if imageName != nil
        {
            button.setImage(UIImage(named:imageName!), for: .normal)
        
        }
        button.addTarget(target, action: action, for: .touchUpInside)
        button.setTitle(title1, for: .normal)
        button.setTitleColor(UIColor.darkGray, for: .normal)
        button.setTitleColor(UIColor.orange, for: .highlighted)
        button.titleLabel?.font = UIFont.systemFont(ofSize: 15)
    
       
         button.sizeToFit()
            
         self.customView = button
    }


 }
